import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer'

const modules = import.meta.globEager("./**/*.ts")
// import.meta.globEager 代替 require.context 自动导入文件 类似：const files = require.context('.', false, /\.ts$/);
const mockModules:any[] = []
Object.keys(modules).forEach(key =>{
  if(key.includes("/_")) return
  mockModules.push(...modules[key].default)
})

/**
 * Used in a production environment. Need to manually import all modules
 */
export function setupProdMockServer(){
  createProdMockServer(mockModules)
}